<template>
	<view class="container">
		<view class="bg">

		</view>

		<view class="steps-wrapper">

			<view class="top-title">
				<view class="title">
					完善信息
				</view>
				<view class="">
					请仔细填写以下信息进行认证
				</view>
			</view>
			<view class="steps-content">
				<view class="steps-item " :class="{ active: [1].includes(stepIndex) }">

					<view class="txt">
						<view class="">
							<image src="/static/icon/step_1_sel.png" mode="widthFix"></image>
						</view>
						<view class="">
							经营信息
						</view>
					</view>

				</view>

				<view class="steps-item" :class="{ active: [2].includes(stepIndex) }">

					<view class="txt">
						<view class="">
							<image src="/static/icon/step_2.png" mode="widthFix"></image>
						</view>
						<view class="">
							店铺认证
						</view>
					</view>

				</view>
				<view class="steps-item" :class="{ active: [3].includes(stepIndex) }">
					<view class="txt">
						<view class="">
							<image src="/static/icon/step_3.png" mode="widthFix"></image>
						</view>
						<view class="">
							签名确认
						</view>
					</view>

				</view>

			</view>
			<view class="progress">
				<progress :percent="stepIndex==1?10:stepIndex==2?50:90" stroke-width="3"></progress>
				<image src="/static/icon/dot.png" mode=""
					:class="stepIndex==1?'left':stepIndex==2?'center':'right'">
				</image>
			</view>
		</view>

		<!-- <realName :submitShow="false" v-if="stepIndex == 1" @upBtn="upBtn" @nextBtn="nextBtn"></realName> -->
		<operate v-if="stepIndex == 1" :submitShow="false" ref="childOperateRef" @upBtn="upBtn" @nextBtn="nextBtn">
		</operate>
		<!-- <bank v-if="stepIndex == 3" @upBtn="upBtn" @nextBtn="nextBtn"></bank> -->
		<supplement v-if="stepIndex == 2" @upBtn="upBtn" @nextBtn="nextBtn"></supplement>
		<sign v-if="stepIndex == 3" @upBtn="upBtn" @nextBtn="nextBtn" :scanResult="scanResult" :infor="infomation"
			:merchantType="type">
		</sign>
	</view>
</template>

<script setup>
	import {
		onLoad,
		onShow
	} from "@dcloudio/uni-app";
	import {
		ref,
		reactive,
		onMounted
	} from "vue";
	import {
		showToast
	} from "@/utils/toast";
	import operate from "./component/operate/index.vue";
	import supplement from "./component/supplement/index.vue"
	import rate from "./component/rate/index.vue"
	import realName from "@/components/identification/realName/index.vue";
	import bank from "./component/bank/index.vue";
	import sign from "./component/sign/index.vue";
	import {
		useStore
	} from "@/store";
	const store = useStore();
	onLoad((val) => {
		scanResult.value = val.scanResult;
		type.value = val.type;
		console.log("type=" + type.value)
	});
	onShow(() => {
		// stepIndex.value = 1
	});
	let scanResult = ref(null)
	let type = ref(null) //区分是个体户还是公司
	//法人信息
	let corporateInformation = ref({})
	// 经营信息
	let businessInformation = ref({})
	// 结算信息
	let settlementInformation = ref({})
	// 店铺认证
	let supplementaryInformation = ref({})
	// 结算费率
	let settlementRate = ref({})
	// 获取子组件引用
	const childOperateRef = ref(null);
	// 步骤索引
	let stepIndex = ref(1);
	let infomation = ref({});
	let nextBtn = (val, type) => {
		stepIndex.value += 1;
		console.log("stepIndex.value", stepIndex.value)
		// if (type == 1) {
		// 	corporateInformation.value = val
		// }
		if (type == 2) {
			businessInformation.value = val
		}
		// if (type == 3) {
		// 	settlementInformation.value = val
		// }
		if (type == 4) {
			supplementaryInformation.value = val
		}
		// if (type == 5) {
		// 	settlementRate.value = val
		// }
		if (stepIndex.value === 3) {
			infomation.value = {
				corporateInformation: corporateInformation.value,
				businessInformation: businessInformation.value,
				settlementInformation: settlementInformation.value,
				supplementaryInformation: supplementaryInformation.value,
				settlementRate: settlementRate.value

			}
			// let infoStr = JSON.stringify(infomation)
			// uni.redirectTo({
			// 	url: `/authentication/lebrush/index?info= ${encodeURIComponent(infoStr)}&type=INDIVIDUAL&sn=${scanResult.value}`,
			// });


		}
	}
	let upBtn = () => {
		stepIndex.value -= 1;
		console.log("stepIndex.value", stepIndex.value)
		if (stepIndex.value === 0) {
			uni.navigateTo({
				url: `/pagesLogin/merchantRegistration/index?selectTypeShow=true`,
			});
		}
	}
</script>
<style lang="scss" scoped>
	@import "./index.scss";
</style>